<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../inc.jsp"></jsp:include>
	
<meta http-equiv="X-UA-Compatible" content="edge" />
<title>出票完成查询页面</title>

<script type="text/javascript">
$(function(){
	//加载表格信息
	$('#table').datagrid({
		url:'${ctx}/search/getBuyerList?orderStatus=4&temp='+Math.random(),
		width:1600,
		striped : true,
		singleSelect : true,
		idField : 'flightIdList',
		pageList : [5,10,20],
		sortName:'toStartDate',
		sortOrder:'asc',
		method : 'get',
		toolbar:'#toolbar',
		pagination:true,
		/*queryParams: {
			msgTime: '${message.startTime}'
		},*/
		columns:[[
		    {
				width : '80',
				title : 'id',
				field : 'id',
				hidden : true,
				sortable : true
			},{
				width : '220',
				title : '订单号',
				align : 'center',
				field : 'orderNumber',
				sortable : true,
			},
			{
				width : '80',
				title : '航班号',
				align : 'center',
				field : 'airlineId',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						if(row.list.length == 1){
							table='<table class="tableOntab" style="width:60px;"><tr><td>'+((row.list))[0].airlineNumber+'</td></tr></table>';
						}else if(row.list.length == 2){
							table='<table class="tableOntab" style="width:60px;"><tr><td>'+((row.list))[0].airlineNumber+'</td>'+'</tr><tr>'+'<td class="borderNone">'+((row.list))[1].airlineNumber+'</td></tr></table>';
						};
					};
					return table;
			}
		},{
			width : '135',
			title : '出发',
			align : 'center',
			field : 'charterTypeStr',
			formatter : function(value,row){
				var table;
				if(row.list != null && row.list.length > 0){
					if(row.list.length == 1){
						table='<table class="tableOntab" style="width:100px;"><tr><td>'+(row.list)[0].deptCity+'('+(row.list)[0].deptCode+')</td></tr></table>';
					}else if(row.list.length == 2){
						table='<table class="tableOntab" style="width:100px;"><tr><td>'+(row.list)[0].deptCity+'('+(row.list)[0].deptCode+')'+'</td>'+'</tr><tr>'+'<td class="borderNone">'+(row.list)[1].deptCity+'('+(row.list)[1].deptCode+')'+'</td></tr></table>';
					}
				}
				return table;
			}
		},{
			width : '130',
			title : '到达',
			align : 'center',
			field : 'scheduleId',
			formatter : function(value,row){
				var table;
				if(row.list != null && row.list.length > 0){
					if(row.list.length == 1){
						table='<table class="tableOntab" style="width:100px;"><tr><td>'+(row.list)[0].arrCity+'('+(row.list)[0].arrCode+')</td></tr></table>';
					}else if(row.list.length == 2){
						table='<table class="tableOntab" style="width:100px;"><tr><td>'+(row.list)[0].arrCity+'('+(row.list)[0].arrCode+')'+'</td>'+'</tr><tr>'+'<td class="borderNone">'+(row.list)[1].arrCity+'('+(row.list)[1].arrCode+')'+'</td></tr></table>';
					}
				}
				return table;
			}
		},{
			width : '80',
			title : '出发日期',
			align : 'center',
			field : 'scheduleIdStr',
			formatter : function(value,row){
				var table;
				if(row.list != null && row.list.length > 0){
					if(row.list.length == 1){
						table='<table class="tableOntab" style="width:80px;"><tr><td>'+(row.list)[0].deptDate+'</td></tr></table>';
					}else if(row.list.length == 2){
						table='<table class="tableOntab" style="width:80px;"><tr><td>'+(row.list)[0].deptDate+'</td>'+'</tr><tr>'+'<td class="borderNone">'+(row.list)[1].deptDate+'</td></tr></table>';
					}
				}
				return table;
			}
		},{
			width : '55',
			title : '出发时刻',
			align:'center',
			field : 'journeyType',
			formatter : function(value,row){
				var table;
				if(row.list != null && row.list.length > 0){
					if(row.list.length == 1){
						table='<table class="tableOntab" style="width:50px;"><tr><td>'+CommonConverter.formatFlightTime((row.list)[0].deptTime)+'</td></tr></table>';
					}else if(row.list.length == 2){
						table='<table class="tableOntab" style="width:50px;"><tr><td>'+CommonConverter.formatFlightTime((row.list)[0].deptTime)+'</td>'+'</tr><tr>'+'<td class="borderNone">'+CommonConverter.formatFlightTime((row.list)[1].deptTime)+'</td></tr></table>';
					}
				}
				return table;
			}
		},{
			width : '55',
			title : '到达时刻',
			align:'center',
			field : 'toDate',
			formatter : function(value,row){
				var table;
				if(row.list != null && row.list.length > 0){
					
					if(row.list.length == 1){
						var backIntervalDay=(row.list)[0].intervalDay;
						var _backIntervalDay="";
						if (backIntervalDay >= 1){
							_backIntervalDay="+"+backIntervalDay;
						}; 
						table='<table class="tableOntab" style="width:50px;"><tr><td>'+CommonConverter.formatFlightTime((row.list)[0].arrTime)+_backIntervalDay+'</td></tr></table>';
					}else if(row.list.length == 2){
						var toIntervalDay=(row.list)[0].intervalDay;
						var backIntervalDay=(row.list)[1].intervalDay;
						var _toIntervalDay="";
						var _backIntervalDay="";
						if (toIntervalDay >= 1){
							_toIntervalDay="+"+toIntervalDay;
						}; 
						if (backIntervalDay >= 1){
							_backIntervalDay="+"+backIntervalDay;
						}; 
						table='<table class="tableOntab" style="width:50px;"><tr><td>'+CommonConverter.formatFlightTime((row.list)[0].arrTime)+_toIntervalDay+
						'</td>'+'</tr><tr>'+'<td class="borderNone">'+CommonConverter.formatFlightTime((row.list)[1].arrTime)+_backIntervalDay+'</td></tr></table>';
					}
				}
				return table;
			}
		},{
			width : '120',
			title : '状态',
			align:'center',
			field : 'placeHolder',
			formatter : function(value,row){
				var orderStatus=CommonConverter.toOrderBizStatusStr(row.orderStatus);
				return orderStatus;
			}
		},{
			width : '50',
			title : '单价',
			align:'center',
			field : 'sellingPrice',
		},{
			width : '50',
			title : '数量',
			align:'center',
			field : 'purchQuantity',
		},{
			width : '50',
			title : '总价',
			align:'center',
			field : 'sum',
		},{
			width : '250',
			title : '操作',
			align:'center',
			field : 'fareSaleStr',
			formatter:function(value,row){
				var str = '<span class="mynewBtn" onclick=getTickedDetail("'+row.orderNumber+'")>查看票号</span>';
				return str;
			}
		}
		] ]
	});
	//点击查询 重新加载列表
	$("#query").click(function(){
		//出发到达城市清空处理
		alsoempty($("#homecity_name"),$("#_startCity"));
		alsoempty($("#getcity_name"),$("#_endCity"));
		//获取参数
		var orderNumber=$("#_orderNumber").val();
		var toStartAirportCode=$("#_startCity").val();
		var toEndAirportCode=$("#_endCity").val();
		var toStartDate=$("#_startTime").datebox('getValue');
		var toEndDate=$("#_endTime").datebox('getValue');
		if(typeof(toStartAirportCode) == 'undefined'){
			toStartAirportCode = "";
		}
		if(typeof(toEndAirportCode) == 'undefined'){
			toEndAirportCode = "";
		}
		$('#table').datagrid('load',{"orderNumber":orderNumber,"toStartAirportCode":toStartAirportCode,"toEndAirportCode":toEndAirportCode,"toStartDate":toStartDate,"toEndDate":toEndDate,"temp":Math.random()});
		$('#table').datagrid('unselectAll');//清除全选
	});
})
//查看票号弹出框
	function getTickedDetail(orderNumber) {
		//console.log(orderNumber)
		layer.open({
			type: 2,
			title: ['订单管理-查看票号','background-color:#00B2EE; color:#fff;'],
			shadeClose: true,
			shade: 0.3,
			area: ['1020px', '500px'],  
			content: ['${ctx}/order/orderTickets/'+orderNumber, 'no'], //iframe的url，no代表不显示滚动条
		});
	};
	//如果为空  对应的文本框为空
	function alsoempty(a,b){
		if(a.val() == "中文/拼音"){
			b.val("");
		};
	};
</script>
</head>
<body>
	<jsp:include page="../head.jsp"/>
	<div>
		<div>
			<ul class="searchBox">
				<li>订单号：<input style='width:120px;' class="easyui-textbox" id="_orderNumber" /></li>
				<li>出发城市：
				<input type="text" value="" size="15" id="homecity_name" name="homecity_name" style="width:150px;height: 18px" mod="address|notice" mod_address_source="hotel" mod_address_suggest="" mod_address_reference="_startCity" mod_notice_tip="中文/拼音" />
					<input id="_startCity" name="_startCity" type="hidden" value="" />
				</li>
				<li>到达城市：
				<input type="text" value="" size="15" id="getcity_name" name="getcity_name" style="width:150px;height: 18px" mod="address|notice" mod_address_source="hotel"  mod_address_reference="_endCity" mod_notice_tip="中文/拼音" />
					<input id="_endCity" name="_endCity" type="hidden" value="" />
				</li>
				<li>
					出发时间 ：<input class="easyui-datebox" id="_startTime" style="width: 120px" />
					至<input class="easyui-datebox" id="_endTime" style="width: 120px" /></li>
				<li>
				<li><button class='query' id="query">查询</button></li>
			</ul>
		</div>
		<div>
				<table id="table" class="easyui-datagrid"></table>
		</div>
	</div>
<script type="text/javascript" src="${ctx }/jslib/airport/fixdiv.js"></script>
<script type="text/javascript" src="${ctx }/jslib/airport/address.js"></script>
<jsp:include page="../footer.jsp"/>
</body>
</html>